package com.yunhe.mybatis.common.jdbc;

import com.yunhe.mybatis.common.utils.PropertiesHandler;
import org.apache.ibatis.datasource.unpooled.UnpooledDataSourceFactory;

import javax.sql.DataSource;
import java.util.Properties;

public class DruidDataSourceFactory extends UnpooledDataSourceFactory {

    @Override
    public DataSource getDataSource() {
        DataSource dataSource = null;
        Properties druidConfig = new PropertiesHandler("druid").getProperties();
        try {
            dataSource = com.alibaba.druid.pool.DruidDataSourceFactory.createDataSource(druidConfig);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dataSource;
    }
}
